# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: Exp $

inherit eutils

DESCRIPTION="Lightweight connection pooler for PostgreSQL."
HOMEPAGE="https://developer.skype.com/SkypeGarage/DbProjects/PgBouncer"
SRC_URI="http://pgfoundry.org/frs/download.php/1356/pgbouncer-1.0.7.tgz"

LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~ppc ~ppc64 ~sparc ~x86"
IUSE=""

DEPEND="=dev-db/libpq-8*
        dev-libs/libevent"

src_compile() {
    econf || die "econf failed"
    emake || die "emake failed"
}

src_install() {
    emake DESTDIR="${D}" install || die "make install failed"

    dodoc NEWS README

    # Move config sample to doc location
    mv "${D}"/usr/share/doc/"${PN}"/* "${D}"/usr/share/doc/"${PF}"/
    rm -fr "${D}"/usr/share/doc/"${PN}"

    newinitd ${FILESDIR}/pgbouncer.initscript ${PN}
    dosed "s:@@doc_dir@@:/usr/share/doc/${PF}:" /etc/init.d/${PN}
}
